Copyright: ©1995 TopSpeed Corporation
Citation: ©1995 TopSpeed Corporation


Contents
Guide to the Clarion 1.5 Examples

The examples programs included with Clarion for Windows 1.5 demonstrate a variety of Clarion programming techniques. Some of these are hand-coded programs showing the power of the Clarion language, and others use the Application Generator to demonstrate its capabilities.

Application Generator Examples	Hand-coded Examples

ORDERS.DCT	Blinds

CheckBox	Calculator

ComboBox	CDPlayer

HexEdit	Domination

Property	Dots

Relation	Gauge

Samples	GraphVBX

Tree	Hello

Video	LIB Maker

WizDemo


Application Generator Examples

ORDERS.DCT Application Wizard Demonstration

A dictionary file--ORDERS.DCT--is already set up to make the most of the Application Wizard. This file contains the data file declarations for a simnple order-entry program (this is also the dictionary used by the Tree example).

The ORDERS.DCT file is in the \CW15\EXAMPLES\APPS\ORDERS directory. To use the Application Wizard on this dictionary:

1.	Choose File [image] New.

The New dialog appears.

2.	Select the Application tab.

3.	Select the \CW\EXAMPLES\APPS\ORDERS directory from the Directories list.

4.	Type ORDERS.APP in the File Name field.

5..	Uncheck the Use Quick Start Wizard box, then press the Create button.

The Application Properties dialog appears.

6.	Press the ... button to the right of the Dictionary File entry box.

The Select Dictionary dialog appears.

7.	Highlight the \CW15\EXAMPLES\APPS\ORDERS\ORDERS.DCT file and press the OK button.

8.	Check the Application Wizard box, then press the OK button.

9.	Press the Next button.

10.	Press the Next button.

11.	Press the Finish button.

The Application Wizard creates the application.

CheckBox Demonstrating the Xbase Logical Fields Using CHECK

The CHKBOX.APP file is in the \CW15\EXAMPLES\APPS\DB3LOGIC directory. This application demonstrates how to use a CHECK control to maintain an Xbase Logical data type (declared as a STRING(1) in Clarion). Xbase Logical fields contain a T or F or t or f or Y or N or y or n instead of zero (0) or one (1), which is the normal CHECK control USE variable assignment. This contains two lines of embedded source code using PROP:TrueValue and PROP:FalseValue to change the values assigned by the CHECK control to its USE variable.

ComboBox Demonstrating the FileDropCombo Control Template

The COMBOBOX.APP file is in the \CW15\EXAMPLES\APPS\COMBO directory. This application demonstrates the FileDropCombo Control Template in its Form procedure.

The FileDropCombo Control Template creates a COMBO control (a combination of an ENTRY control and a LIST control with the DROP attribute) in which the user can either choose an entry from a dropdown list, or type in a new value not in the list. This Control Template allows the user to add the new entry to the file from which the dropdown list of choices comes, so the new entry is available to all users the next time.

There are two ways to use this Control template, and this example program demonstrates both methods:

Displaying data from the lookup file and storing the same data in the COMBO controls USE variable. This means the template can directly add new records to the lookup file, without requiring a separate update (Form) procedure.

Displaying a description from the lookup file in the COMBO control but storing a code number in the Control templates target variable. This means the template can add new records to the lookup file only by using a separate Update (Form) procedure,

HexEdit Hand-coded Procedures and Functions in the Application Generator

The HEXEDIT.APP file is in the \CW15\EXAMPLES\APPS\HEXEDIT directory. This application is a fully-functional Windows Hexadecimal file editor which demonstrates mixing hand-coded procedures and functions (using the Source Template) with generated procedures in the Application Generator.

This is an MDI application, allowing you to load multiple files at once. It also reads the files in the background (using the TIMER attribute) allowing you to view the beginning of large files before the whole file read is complete. It has a right-click popup menu to edit or close the file, duplicating local menu items in the editing procedure that merge into the Application Frames menu. This application uses edit-in-place on the LIST control to edit the Hexadecimal values.

The Source Procedure Template allows you to create either a PROCEDURE or a FUNCTION for use within an Application Generator application. This example contains one hand-coded PROCEDURE (the main editong logic) and two hand-coded FUNCTIONs (which translate ASCII characters to their Hexdecimal representation and back again). The FUNCTIONs both receive parameters passed to them from the PROCEDURE.

Property Runtime Property Assignments

The PROPS.APP file is in the \CW15\EXAMPLES\APPS\PROPERTY directory. This application demonstrates how runtime property assignments can be used to dynamically alter the look and/or behavior of your programs.

Some of the properties demonstrated (along with many more) are:

PROP:Text	Changing the contents of an IMAGE control.

PROP:ImageBits	Moving the contents of an IMAGE control into and out of a MEMO field.

PROP:ImageBlob	Moving the contents of an IMAGE control into and out of a BLOB field.

PROP:SelStart	Positioning the insertion point in an ENTRY control.

PROP:SelEnd	Marking a block (along with PROP:SelStart) in an ENTRY control.

PROP:Xpos	Positioning a control (along with PROP:Ypos).

PROP:Width	Resizing a control (along with PROP:Height).

Relation Multiple Related Browse Lists

The RELATION.APP file is in the \CW15\EXAMPLES\APPS\RELATION directory. This application demonstrates how multiple BrowseBox Control Templates can be used to easily display related Child records of the currently highlighted Parent record in another BrowseBox LIST Control.

The highlight of this application is the BigBrowse procedure which uses eleven (11) LIST controls to display four (4) generations of related records -- and does it with NO embedded source code at all -- Parent >> Child >> GrandChild >> GreatGrandChild.

Samples List Box Tips and Tricks

The SAMPLES.APP file is in the \CW15\EXAMPLES\APPS\SAMPLES directory. This application demonstrates:

Tagging entries in a LIST box

Editing entries in a LIST box in Place

Drag and Drop between controls on the same window

Drag and Drop between controls on separate windows

Drag and Drop between controls in separate applications

Tree Demonstrating the RelationTree Control Template

The TREE.APP file is in the \CW15\EXAMPLES\APPS\ORDERS directory. This application is an order entry program that demonstrates how to use the RelationTree Control Template to easily display related Parent-Child records in a LIST Control, using the Tree metaphor.

The Tree control displays three levels of records (Customer >> Order >> Item), perfroms a lookup from the Items into the Products to display the products description, and uses icons and color to distinguish the levels in the tree. It also has a right-click popup menu to call a separate Update (Form) procedure for each file, depending upon which file the currently highlighted tree entry is from. These Update procedures can also be called from the update buttons below the tree.

This example contains several very nicely formatted reports, including an Invoice and 3-up mailing labels. It also demonstrates using the Page Form band in reports to create pre-printed forms.

Video Conditional Icons in a Tree Control

The VIDEO.APP file is in the \CW15\EXAMPLES\APPS\VIDEO directory. This application is a movie rental database that also demonstrates the RelationTree Control Template and conditionally displays different icons in the tree, based upon the reviewers rating of the film. This application also demonstrates how to create a splash screen in the Application Generator.

The database contains a Many to Many relationship between the Movies and Stars files, which is resolved by the Stars2Movies join file. This join file is used to enable the lookup that allows the names of the stars in each movie to display in the tree at the lowest level.

WizDemo Wizard Creation

The WIZDEMO.APP file is in the \CW15\EXAMPLES\APPS\WIZARD directory. This application demonstrates how to create and use your own Wizards in the Application Generator.


Hand-coded Examples

Blinds Image Display and Graphic Controls

The BLINDS.CLW file is in the \CW15\EXAMPLES\SRC\BLINDS directory. This program demonstrates a non-MDI application with a menu and toolbar which will display any graphic image. A SPIN control allows the user to open and close the blinds (like venetian blinds on a window). The blinds are a group of BOX controls that are dynamically resized based upon the value of the SPIN control.

Calculator A 10-Key Calculator

The CWCALC.CLW file is in the \CW15\EXAMPLES\SRC\CALC directory. This program is a fully functional calculator.

CDPlayer Demonstrating Windows API Calls

The CDPLAYER.CLW file is in the \CW15\EXAMPLES\SRC\CDPLAYER directory. This program is a fully functional Compact Disk player which demonstrates making calls to the Windows MultiMedia API. It demonstrates the API calls needed to make an application stay on top and it also automatically shuts down when Windows shuts down. In addition to all the Windows API techniques, this program makes extensive use of Drag and Drop.

Domination A Strategy Game

The DOMIN.CLW file is in the \CW15\EXAMPLES\SRC\DOMIN directory. This program is a fully functional Windows-based strategy game.

Dots Demonstrating Graphic Controls

The CONNDOTS.CLW file is in the \CW15\EXAMPLES\SRC\DOTS directory. This program demonstrates a non-MDI application with a menu and toolbar which will display dots when the user drags the mouse. Once the user releases the mouse button, the program draws lines between each dot placed on the window.

Gauge Relative Performance Benchmarks

The CWGAUGE.CLW file is in the \CW15\EXAMPLES\SRC\GAUGE directory. This program demonstrates using DDE to talk to applications built in Clarion for Windows and other products. It also benchmarks Clarion for Windows performance in two areas: computational speed using the standard Sieve of Erathosthenes (a prime number generation algorithm), and video display speed.

To compare relative performance, CWGAUGE launches programs written in Clarion for Windows, Delphi, Visual Basic, and PowerBuilder. Each products benchmark programs use exactly the same algorithms, so that the performance comparisons are valid. Full source code is provided for each program in all langauges.

You can, of course, always execute the Clarion performance benchmark programs (they are one-piece executables). You can also always execute the Delphi benchmarks (they are also one-piece executables).

The Visual Basic benchmark programs require that you either have Visual Basic 3.0 installed on your computer, or a copy of the VBRUN300.DLL runtime library (which we do not ship with Clarion for Windows) somewhere in your path.

The PowerBuilder benchmarks require that you either have PowerBuilder 4.0 installed on your computer, or the following PowerBuilder runtime library files (which we do not ship with Clarion for Windows):

PBVBX040 DLL        69,568  04-01-95  4:01a

PBBGR040 DLL       594,656  04-01-95  4:01a

PBCMP040 DLL       252,048  04-14-95  4:01a

PBDBI040 DLL       158,400  04-01-95  4:01a

PBDBL040 DLL         6,912  04-01-95  4:01a

PBDEC040 DLL        38,432  04-01-95  4:01a

PBDWE040 DLL     1,197,344  04-01-95  4:01a

PBDWO040 DLL       125,952  04-01-95  4:01a

PBECT040 DLL        61,792  04-01-95  4:01a

PBIDBF40 DLL         7,136  04-01-95  4:01a

PBITXT40 DLL         4,608  04-01-95  4:01a

PBLMI040 DLL        44,320  04-01-95  4:01a

PBODB040 DLL       265,824  04-01-95  4:01a

PBOUI040 DLL       148,448  04-01-95  4:01a

PBPRT040 DLL        21,856  04-01-95  4:01a

PBRTE040 DLL       620,080  04-14-95  4:01a

PBRTF040 DLL       664,288  04-14-95  4:01a

PBSHR040 DLL       142,048  04-01-95  4:01a

PBTYP040 DLL       686,080  04-01-95  4:01a

GraphVBX Demonstrating a .VBX Custom Control

The GRAPHVBX.CLW file is in the \CW15\EXAMPLES\SRC\GRAPHVBX directory. This program demonstrates an MDI application using a .VBX Custom control. This application uses the ChartBuilder GRAPH.VBX to create Pie, Bar, and Gantt charts.

Hello The Standard .EXE Size Benchmark

The HELLO.CLW file is in the \CW15\EXAMPLES\SRC\HELLO directory. This program contains the seven lines of Clarion code that create a minimum Hello World application. The project is set to produce a one-piece Windows executable which does not require any .DLL or runtime library. When compiled, this shows the minimum executable program size, which you can benchmark against any other products Hello World program size. This program also demonstrates the elegant simplicity of Clarion language source code; a similar program in C or C++ would take several pages of code to accomplish.

LibMaker Make a TopSpeed .LIB for any .DLL

The LIBMAKER.CLW file is in the \CW15\EXAMPLES\SRC\LIBMAKER directory. This application is a fully-functional utility that creates a.LIB file in the TopSpeed format from any .DLL (or multiple .DLLs), whether that .DLL has been compiled with a TopSpeed compiler or not. This allows you to link any Windows .DLL to a Clarion for Windows program. One .LIB file can provide the linking information to multiple .DLLs.